#ifndef PLAYER_H
#define PLAYER_H


#include <system/application.h>
#include <maths/vector3.h>
#include <maths/math_utils.h>
#include <graphics/mesh.h>
#include <graphics/primitive.h>
#include <graphics/model.h>
#include <graphics/mesh_instance.h>
#include <system/platform.h>
#include <assets/obj_loader.h>

#include <assets\png_loader.h>
#include <graphics/mesh_instance.h>
#include <graphics/mesh.h>
#include <input/sony_controller_input_manager.h>
#include "GameObject.h"

#include "graphics\renderer_3d.h"
#include "graphics\sprite.h"
#include "graphics\vita\texture_vita.h"
#include "graphics\sprite_renderer.h"
#include "graphics\sprite_renderer.h"
#include <tgmath.h> 
#include <input/sony_controller_input_manager.h>


class Player: public GameObject
{
public:
	Player();
	~Player();
	
	//-- Set player properties
	void SetLocalScale(abfw::Vector3 scale);
	inline void SetCurrentPowerUpAmount(int value) {mCurrentPowerUpAmount = value;};
	inline void SetPowerLevel(int value) {mPowerLevel += value;};
	inline void ResetPowerlevel() {mPowerLevel = 0;};
	inline void SetPowerupAvailable(bool value) {mPowerupAvailable = value;};
	void AddHealth(float value);

	abfw::Matrix44 GetLocalScale();
	abfw::Vector3 GetPlayerRotate();
	abfw::Vector3 GetPlayerMove();

	//-- Get rotation based on PS Vita input
	float CalculateRotationAngle(abfw::SonyControllerInputManager* input);

	//-- Reset position
	void Reset();

	//-- Update player
	void Update(abfw::SonyControllerInputManager* input, abfw::Matrix44 marker);
	
	void Draw(abfw::Renderer3D* render3D);
	void DrawHud(abfw::SpriteRenderer* render2D);

	inline int GetCurrentPowerUpAmount() {return mCurrentPowerUpAmount;};
	inline int GetPowerLevel() {return mPowerLevel;};
	inline bool IsPowerupAvailable() {return mPowerupAvailable;};
	float GetHealth();

	
private:

	void CheckPowerLevel();

private:

	abfw::Matrix44 mRotationX;
	abfw::Matrix44 mRotationZ;

	abfw::Matrix44 mScale;
	abfw::Matrix44 mTranslation;

	abfw::Vector3 mPlayerRotate;
	abfw::Vector3 mPlayerMove;

	abfw::PNGLoader mPngLoader;
	float mLastAngle;
	float mOffset;

	//-- health
	float mHealth;

	int mPowerLevel;
	int mCurrentPowerUpAmount;
	bool mPowerupAvailable;
};

#endif